# 判断是否为有效句柄
import time

from win32gui import IsWindow, IsWindowEnabled, IsWindowVisible, FindWindow, GetWindowPlacement


# 判断是否为有效句柄
def is_valid_hwnd(hwnd):
    if IsWindow(hwnd) and IsWindowEnabled(hwnd) and IsWindowVisible(hwnd):
        return True
    return False


while True:
    markHwnd = FindWindow("SearchResultWindow2", 'SearchResultWindow2')  # 在查询时，这个会出现，然后下面那个会跟着出现
    hwnd = FindWindow("PerryShadowWnd", '')
    print(is_valid_hwnd(markHwnd),  is_valid_hwnd(hwnd), end=' ') 
    [_, top, _, bottom] = GetWindowPlacement(markHwnd)[4]  # 下拉列表的坐标
    height = bottom - top
    print(height)
    time.sleep(0.1)